package com.tanhua.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.domain.AnalysisByDay;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface AnalysisByDayMapper extends BaseMapper<AnalysisByDay> {


    //统计总数
    @Select("select sum(DISTINCT num_registered) from tb_analysis_by_day")
    Long queryCumulativeUsers();


    //统计日期范围内活跃总数
    //SELECT SUM(DISTINCT num_active) FROM tb_analysis_by_day WHERE record_date<="2020-09-25" AND record_date>="2019-09-25";
    @Select("select sum(DISTINCT num_active) from tb_analysis_by_day where record_date<=#{todayStr} and record_date>=#{passDay}")
    Long queryActivePass(@Param("todayStr") String todayStr, @Param("passDay") String passDay);

    //统计新增 活跃 次日留存
    @Select("SELECT SUM(DISTINCT #{type}) FROM tb_analysis_by_day WHERE record_date BETWEEN #{startDate} AND #{endDate}")
    Long queryAARPass(@Param("startDate") String sd, @Param("endDate") String ed, @Param("type") String type);
}